Skip to content

feat(pre-parser): check particles against the 받침 - #54

Merged
Solype merged 6 commits into
mainfrom
feat/17-particles-against-batchim
Nov 15, 2026
Merged

Solype merged 6 commits into
mainfrom
feat/17-particles-against-batchim

Conversation

@Solype

@Solype Solype commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Closes #17

The pre-parser now warns (BadBatchim) when a particle with two forms is in the form of the other 받침, and names the right form.

  • Declared and used names: 끝는 → 끝은, 나을 → 나를.
  • Types, keywords, booleans: 정수을, 참예요, 값예요; (으)로 too (소수으로 → 소수로).
  • Numbers, read in Sino-Korean from the last digit (or 십 백 천… / 영 for 0): 1를 → 1을, 2을 → 2를.
  • After ): the last thing read inside, (가 + 나)을 checks 나, ((가 + 3))를 checks 3.

All these checks go through one check_batchim. pre_parser.rs is split into classify.rs, verbs.rs and names.rs.

scripts/missing.sh now shows, under each MISS of a checks.sh, the program and the whole compiler stderr.

Checks

  • cargo fmt --check, cargo test: 1387 passed
  • scripts/run_samples.sh: 61/61
  • scripts/missing.sh 17: 45/45

The methods of PreParser move, unchanged, into sibling files by task:
one lexer token into parser tokens (classify.rs), the verbs in 다
(verbs.rs), the declared names (names.rs). pre_parser.rs keeps the
entry point, the struct and run.
…other 받침

A declaration whose particle has two forms (끝는, 나은) now gives the
BadBatchim warning with the right form (끝은, 나는). expected_form picks
the form from the 받침 of the last syllable: in a pair of
NAME_PARTICULES, the first one follows a 받침.

The pre-parser keeps its warnings in a field, so that every pass can
push one, and declared_names is split into is_parameter,
declared_variable and NameScan.

Refs #17
…ames

The BadBatchim warning now covers:
- a particle after a number, against its Sino-Korean reading: the last
  digit, or 영 when it is 0 (십, 백… have a 받침 like it): 1를 → 1을;
- a type, a keyword or a boolean with its particle: 정수을, 참예요;
- every name cut with its particle, used or declared (split_name).

(으)로 and 의 have no form in NAME_PARTICULES and are not checked.

Refs #17
…g.sh

With issues given (or found from the branch), each MISS of a checks.sh
now lists its program with line numbers, then the whole stderr and the
exit code of the compiler on it, instead of only the last line.
Numbers, types / keywords / booleans and declared names now share
check_batchim(shown, read, written, particle, span). expected_form looks
in every particle, so (으)로 after a type is checked too.

WIP: the particle after `)` (Refs #17) is not done yet: it still has a
debug eprintln, and 7 tests fail with UnknownIdentifier("를").
The particle after one or more `)` follows the last thing read inside:
(가 + 나)를 checks 나, ((가 + 3))를 checks 3. Any other last token keeps
the particle without a check, as before.

Closes #17
@Solype Solype linked an issue Nov 15, 2026 that may be closed by this pull request
7 tasks
@Solype
Solype merged commit 274fc3b into main Nov 15, 2026
1 check passed
@Solype
Solype deleted the feat/17-particles-against-batchim branch November 15, 2026 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pre-parser: check particles against the 받침

1 participant